<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="css/style.css"></link>
</head>
<body>
    <div class="login-form-wrap">
        <h1>黑马程序员</h1>
        <form class="login-form" action="#" id="regist" method="get" autocomplete="off">
            <label>
                <input type="text" id="username" name="username" placeholder="Username..." value="">
            </label>
            <label>
                <input type="password" id="password" name="password" placeholder="Password..." value="">
            </label>
            <input type="submit" value="注册">
        </form>
    </div> 
</body>
<script>
    document.getElementById("regist").onsubmit =function(){
        let username = document.getElementById("username").value;
        let password = document.getElementById("password").value;
        let reg1=/^[a-zA-Z]{4,16}$/;
        let reg2=/^[\d]{6}$/;
        if(!reg1.test(username)){
                alert("用户名验证失败");
                return false;
        }
        if(!reg2.test(password)){
                alert("密码验证失败");
                return false;
        }
        return true;
    }
</script>
</html>